<template>
  <layout>
    <!-- 产品列表 -->
    <a-table
      :dataSource="tableData"
      :columns="tableColumns"
      :rowKey="record => record.member_id"
      :pagination="false"
      :customRow="customTableRow"
      size='small'
      :scroll="{
        x: true
      }"
      bordered
    >
    </a-table>

    <a-pagination
      slot="paging"
      :pageSizeOptions="pageSizes"
      :total="total"
      :show-total="showTotal"
      showSizeChanger
      :pageSize="pageSize"
      v-model="currentPage"
      @showSizeChange="changePageSize"
      @change="changePage"
    >
    </a-pagination>
  </layout>
</template>

<script lang="ts">
import { Mixins, Component, Watch, Vue, Prop } from 'vue-property-decorator'
import EventsMixin from '@/mixin/events'
import { TableMixin, AuthMixin } from '@/mixin'

import TableLayout from '@/layouts/TableLayout.vue'
import CustomForm from '@/components/src/Form'
import { userModule } from '@/store/modules/user'

@Component({
  components: {
    Layout: TableLayout,
    CustomForm,
  }
})
export default class ImportExecl extends Mixins(
  EventsMixin,
  TableMixin,
  AuthMixin
) {
  @Prop({
    type: Array
  })
  public execlData!: Array<any>

  @Prop({
    type: Array
  })
  public execlColumns!: ITable.IColumn[]

  public commonParams = {
    s_a_id: ''
  }

  get isLarge() {
    return userModule.isLarge
  }

  get isPlant() {
    return userModule.isPlant
  }

  // 产品列表搜索条件
  public tableSearch = {
  }

  // 自定义mode
  public customMode = 'search'

  public columns: ITable.IColumn[] = []

  public tableApi = {
  }

  @Watch('execlData', { immediate: true })
  public handlerChangeExecl() {
    this.total = this.execlData.length
    this.getData()
  }

  @Watch('execlColumns', { immediate: true })
  public handleColumnsChange() {
    console.log('execlColumns', this.execlColumns)
    this.columns = this.execlColumns
  }

  public mounted() {
  }

  public async getData() {
    this.tableData = this.execlData.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)
  }
}
</script>

<style scoped lang="less">
.action-button {
  margin: 0px 10px 0px 10px;
}
.upload-button {
  position: relative;
  input {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 2;
    opacity: 0;
  }
}
.form-item-class {
  margin-bottom: 0px;
}
.img-box {
  width: 100px;
  height: 100px;
  margin: 10px;
}
.item-blue {
  color: #1989fa;
}
/deep/ .ant-table tr {
  td, th {
    white-space: nowrap;
  }
}
</style>
